package o;

import android.content.Context;
import android.os.Handler;
import android.os.Looper;
import android.os.RemoteException;
import androidx.annotation.NonNull;
import com.huawei.appgallery.serverreqkit.api.bean.ResponseBean;
import com.huawei.appmarket.framework.coreservice.Status;
import com.huawei.appmarket.service.distribution.authentication.bean.AgdSecurityVerificationRequest;
import com.huawei.appmarket.service.distribution.authentication.bean.AgdSecurityVerificationResponse;
import com.huawei.appmarket.service.externalservice.distribution.download.response.TaskOperationResponse;
import com.huawei.appmarket.service.webview.base.jssdk.control.FullAppStatus;
import java.util.List;
import o.dgz.e;

public class dxv {
    private dxn ˊ;
    private TaskOperationResponse ˋ;
    private Context ˎ;
    private dgz ˏ;
    private Handler ॱ = new dxu(Looper.getMainLooper(), this);

    public dxv(@NonNull Context context, @NonNull dxn o_dxn, @NonNull dgz o_dgz, @NonNull TaskOperationResponse taskOperationResponse) {
        this.ˎ = context;
        this.ˊ = o_dxn;
        this.ˏ = o_dgz;
        this.ˋ = taskOperationResponse;
    }

    public void ˊ(List<String> list) {
        if (ॱ(list)) {
            this.ॱ.sendMessageDelayed(this.ॱ.obtainMessage(1), 600);
        }
        this.ॱ.sendMessageDelayed(this.ॱ.obtainMessage(2), 10000);
    }

    private boolean ॱ(List<String> list) {
        if ((this.ˊ.ॱˊ() & 1) != 0 && doo.ʻ(this.ˎ)) {
            return false;
        }
        int ॱ = dxt.ˋ().ॱ(dxt.ˎ(this.ˊ.ˏ(), this.ˊ.ˊ(), list), -1);
        if (ॱ == 4 || ॱ == 3) {
            return true;
        }
        return false;
    }

    public Handler ˋ() {
        return this.ॱ;
    }

    public void ˊ(int i) {
        Status status = new Status(i);
        status.ˏ(this.ˋ);
        try {
            this.ˏ.ॱ(status);
        } catch (RemoteException e) {
            Logger.e("TimeOutOptimizeManager", "AgdSecurityVerification Remote Exception");
        }
    }

    public void ˊ(ResponseBean responseBean) {
        if ((responseBean instanceof AgdSecurityVerificationResponse) && responseBean.getResponseCode() == 0) {
            AgdSecurityVerificationResponse agdSecurityVerificationResponse = (AgdSecurityVerificationResponse) responseBean;
            if (agdSecurityVerificationResponse.getRtnCode_() == 0) {
                if (ejj.ˊ().ˎ()) {
                    agdSecurityVerificationResponse.ॱ(0);
                }
                new dxp(this.ˎ, this.ˋ, this.ˏ).ˋ(this.ˊ, agdSecurityVerificationResponse);
                return;
            }
            this.ˋ.ˏ(agdSecurityVerificationResponse.getRtnCode_());
            ˊ(8);
            Logger.ˎ("TimeOutOptimizeManager", "call store error rtnCode :" + agdSecurityVerificationResponse.getRtnCode_());
        } else if (responseBean.getResponseCode() == 3) {
            ˊ(7);
            Logger.ˎ("TimeOutOptimizeManager", "call store error responseCode :" + responseBean.getResponseCode());
        } else {
            ˊ(13);
            Logger.ˎ("TimeOutOptimizeManager", "call store error responseCode :" + responseBean.getResponseCode());
        }
    }

    public void ˎ(ResponseBean responseBean) {
        if ((responseBean instanceof AgdSecurityVerificationResponse) && responseBean.getResponseCode() == 0) {
            AgdSecurityVerificationResponse agdSecurityVerificationResponse = (AgdSecurityVerificationResponse) responseBean;
            if (agdSecurityVerificationResponse.getRtnCode_() == 0 && !ejj.ˊ().ˎ()) {
                int ˊ = agdSecurityVerificationResponse.ˊ();
                if (ˊ == 4 || ˊ == 3) {
                    new dxp(this.ˎ, this.ˋ, new e(this) {
                        final /* synthetic */ dxv ॱ;

                        {
                            this.ॱ = r1;
                        }

                        public void ॱ(Status status) {
                            if (status == null || status.ˏ() != 0) {
                                this.ॱ.ˏ();
                            } else {
                                Logger.ˎ("TimeOutOptimizeManager", "start download success");
                            }
                        }
                    }).ˋ(this.ˊ, agdSecurityVerificationResponse);
                    return;
                }
            }
        }
        ˏ();
    }

    public void ˏ() {
        FullAppStatus fullAppStatus = new FullAppStatus();
        fullAppStatus.ˊ(this.ˊ.ʼ());
        fullAppStatus.ˏ(3);
        fullAppStatus.ˊ(0);
        fullAppStatus.appType_ = 2;
        fullAppStatus.callerPkg_ = this.ˊ.ˊ();
        fullAppStatus.contentId_ = this.ˊ.ॱ();
        fullAppStatus.mediaPkg_ = this.ˊ.ˏ();
        fullAppStatus.extendDownloadFlags_ = String.valueOf(this.ˊ.ॱॱ());
        dzd.ॱ(ContentManager.getInstant().getContext()).ॱ(fullAppStatus);
    }

    public void ˊ() {
        FullAppStatus fullAppStatus = new FullAppStatus();
        fullAppStatus.ˊ(this.ˊ.ʼ());
        fullAppStatus.ˏ(0);
        fullAppStatus.ˊ(0);
        fullAppStatus.appType_ = 2;
        fullAppStatus.callerPkg_ = this.ˊ.ˊ();
        fullAppStatus.contentId_ = this.ˊ.ॱ();
        fullAppStatus.mediaPkg_ = this.ˊ.ˏ();
        fullAppStatus.extendDownloadFlags_ = String.valueOf(this.ˊ.ॱॱ());
        dzd.ॱ(ContentManager.getInstant().getContext()).ॱ(fullAppStatus);
        ˊ(0);
    }

    public void ॱ(BaseRequest o_cvu, int i) {
        if ((i == 4 || i == 3) && (o_cvu instanceof AgdSecurityVerificationRequest)) {
            dxt.ˋ().ˊ(dxt.ˎ(this.ˊ.ˏ(), this.ˊ.ˊ(), ((AgdSecurityVerificationRequest) o_cvu).ʼ()), i);
        }
    }
}
